
import React , {Component} from "react";
// import { Switch,Button } from 'antd';
import CommonHead from "../../components/commonHead"
import icon1 from "../../../assets/images/icon1.png"
import banner1 from "../../../assets/images/1.jpg"
import {change_play} from "../../actions"
import {connect} from "react-redux"
@connect(
    state=>({
       playCount:state.playCount
    })
)
export default class Play extends Component{
    constructor(props){
        super(props)
    }

    componentWillMount(){
        var src="";
        const {dispatch}=this.props;
        const urls=new URLSearchParams(location.search).get("url")
        switch(urls){
            case "/font/69b3b122.png" :
            src="/player"
            break;
            case "/font/0092104d.png" :
            src="/star"
            break;
            case "/font/fb4d96b0.png" :
            src="/fan"
            break;
        }
        // console.log(src)
        dispatch(change_play(src,dispatch));
    }
    render(){
        const {match,location,history} = this.props
        const urls=new URLSearchParams(location.search).get("url")
        
        var playcontents;
        if(this.props.playCount!=""){
        playcontents=  this.props.playCount.map((item,idx)=>{
            return (
                <div className="playContent" key={idx}>
                    <div className="contentDiv">
                        <img className="contentImg" src={item.thumb} alt=""/>
                    </div>
                    <div className="contentTip">{item.subject}</div>
                </div>
            )
            })
        }
        return (
           <div className="play">
                <CommonHead urls={urls} show={true}  history={history}/>
                <div className="playContent">
                    <h2 className="playTitle">公众号推荐</h2>
                    <div className="playDiv">
                        <ul className="playUl">
                            <li>
                                <img className="playImg" src={icon1} alt=""/>
                                <span className="playSpan">什么值得买</span>
                                <span className="playIcon" >
                                    <i className="iconfont icon-iconfontadd"></i>
                                    关注
                                </span>
                            </li>
                            <li>
                                <img className="playImg" src={icon1} alt=""/>
                                <span className="playSpan">什么值得买</span>
                                <span className="playIcon" >
                                    <i className="iconfont icon-iconfontadd"></i>
                                    关注
                                </span>
                            </li>
                            <li>
                                <img className="playImg" src={icon1} alt=""/>
                                <span className="playSpan">什么值得买</span>
                                <span className="playIcon" >
                                    <i className="iconfont icon-iconfontadd"></i>
                                    关注
                                </span>
                            </li>
                            <li>
                                <img className="playImg" src={icon1} alt=""/>
                                <span className="playSpan">什么值得买</span>
                                <span className="playIcon" >
                                    <i className="iconfont icon-iconfontadd"></i>
                                    关注
                                </span>
                            </li>
                            
                        </ul>
                    </div>
                    <div>
                        {playcontents}
                    </div>
                </div>
           </div>
        )
    }
}